package h0714;

import java.util.Arrays;
import java.util.Scanner;
/**
  * @description 灰度图存储
  * @author 不知名帅哥
  * @date 2024/7/14 17:23
  * @version 1.0
*/
public class GrayscaleImageStorage {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //行列数
        int row = sc.nextInt();
        int col = sc.nextInt();
        String s = sc.nextLine();
        //去掉前导空格
        int[] array = Arrays.stream(s.trim().split(" ")).mapToInt(Integer::parseInt).toArray();
        int n = array.length / 2;

        int[][] ints = new int[n][2];
        for (int i = 0; i < array.length; i+=2) {
            ints[i/2][0]=array[i];
            ints[i/2][1]=array[i+1];
        }

        int x = sc.nextInt();
        int y = sc.nextInt();

        int[][] image = new int[row][col];
        int k=0;
        int count=0; //计数器
        for (int i = 0; i < image.length; i++) {
            for (int j = 0; j < image[0].length; j++) {
                image[i][j] = ints[k][0];
                count++;
                if (count==ints[k][1]){
                    count=0;
                    k++;
                }
            }
        }
        System.out.println(image[x][y]);
    }
}
